import request from "@/utils/request";
import type {SocEvents,EventDetailVO,SocEventParticipants,SocEventCreateDTO} from "@/api/social/event/type";
import type {PageType} from '@/api/type'

enum API{
    BASE_URL = "/social/event",
    EVENT_PAGE_URL = "/social/event/page",
    EVENT_DETAIL_URL = "/social/event/detail",
    EVENT_REMARK="/social/event/remark",
    EVENT_PARTICIPANT= "/social/event/participant",
    EVENT_REMARK_PAGE="/social/event/remark/page",
    EVENT_PERSON_INFO="/social/event/person",
    CATEGORY="/social/event/category",
    CATEGORY_LIST="/social/event/category/list",
    JOINER_COUNT="/social/event/participant/joiner/count",
    JOINER_PAGE="/social/event/participant/joiner/page",
}

export function reqGetEventPage(query: object){
    return request<PageType<SocEvents>>({
        url: API.EVENT_PAGE_URL,
        method: "get",
        params: query,
    });
}

export function reqGetEventInfo(eventId: string){
    return request<EventDetailVO>({
        url: API.EVENT_DETAIL_URL+"/"+eventId,
        method: "get",
    });
}
export function reqGetEventRemarkPage(query: object){
    return request<PageType<SocEvents>>({
        url: API.EVENT_REMARK_PAGE,
        method: "get",
        params: query,
    });
}
export function reqAddEventParticipant(data: SocEventParticipants){
    return request({
        url: API.EVENT_PARTICIPANT,
        method: "post",
        data
    });
}
export function reqAddEvent(data: SocEventCreateDTO){
    return request<string>({
        url: API.BASE_URL,
        method: "post",
        data
    });
}
export function reqUpdateEvent(data: SocEventCreateDTO){
    return request<string>({
        url: API.BASE_URL,
        method: "put",
        data
    });
}
export function reqEventPersonInfo(userId?: string){
    return request<SocEventParticipants[]>({
        url: API.EVENT_PERSON_INFO+"/"+userId,
        method: "get",
    });
}

export function reqGetEventCategoryList(){
    return request({
        url: API.CATEGORY_LIST,
        method: "get",
    });
}
export function reqGetJoinerCount(){
    return request<number>({
        url: API.JOINER_COUNT,
        method: "get",
    });
}
export function reqGetJoinerPage(query: object){
    return request({
        url: API.JOINER_PAGE,
        method: "get",
        params: query,
    });
}

export function reqCreateEventRemark(data: object){
    return request({
        url: API.EVENT_REMARK,
        method: "post",
        data
    });
}
